//
//  HSNavigationControllerManager.m
//  AFNetworking
//
//  Created by huang on 2018/9/28.
//

#import "HSNavigationControllerManager.h"
#import "HSNavigationController.h"

@implementation HSNavigationControllerManager

+ (instancetype)sharedInstance
{
    static id sharedInstance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [[self alloc] init];
    });
    return sharedInstance;
}

+ (UINavigationController *)navigationControllerWithViewControllerName:(NSString *)viewControllerName
{
    UIViewController *vc = [[NSClassFromString(viewControllerName) alloc] init];
    NSAssert([vc isKindOfClass:[UIViewController class]], @"viewControllerName 必现是 UIViewController");
    
    HSNavigationController *navController = [(HSNavigationController *)[NSClassFromString([HSNavigationControllerManager sharedInstance].navigationControllerString) alloc] initWithRootViewController:vc];
    navController.viewControllerNeedNavigationBarHiddenNames = [HSNavigationControllerManager sharedInstance].viewControllerNeedNavigationBarHiddenNames;
    return navController;
}

- (NSString *)navigationControllerString
{
    UINavigationController *vc = [[NSClassFromString(_navigationControllerString) alloc] init];
    if ([vc isKindOfClass:[UINavigationController class]]) {
        return _navigationControllerString;
    }else {
        return @"HSNavigationController";
    }
}

@end
